package com.ruoyi.web.controller.students;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.student.domain.StudentsTutors;
import com.ruoyi.student.service.IStudentsTutorsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 导师信息Controller
 *
 *
 * @date 2024-04-16
 */
@RestController
@RequestMapping("/students/tutors")
public class StudentsTutorsController extends BaseController
{
    @Autowired
    private IStudentsTutorsService studentsTutorsService;

    /**
     * 查询导师信息列表
     */
    @PreAuthorize("@ss.hasPermi('students:tutors:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentsTutors studentsTutors)
    {
        startPage();
        List<StudentsTutors> list = studentsTutorsService.selectStudentsTutorsList(studentsTutors);
        return getDataTable(list);
    }

    /**
     * 导出导师信息列表
     */
    @PreAuthorize("@ss.hasPermi('students:tutors:export')")
    @Log(title = "导师信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentsTutors studentsTutors)
    {
        List<StudentsTutors> list = studentsTutorsService.selectStudentsTutorsList(studentsTutors);
        ExcelUtil<StudentsTutors> util = new ExcelUtil<StudentsTutors>(StudentsTutors.class);
        util.exportExcel(response, list, "导师信息数据");
    }

    /**
     * 获取导师信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('students:tutors:query')")
    @GetMapping(value = "/{tutorId}")
    public AjaxResult getInfo(@PathVariable("tutorId") Long tutorId)
    {
        return success(studentsTutorsService.selectStudentsTutorsByTutorId(tutorId));
    }

    /**
     * 新增导师信息
     */
    @PreAuthorize("@ss.hasPermi('students:tutors:add')")
    @Log(title = "导师信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentsTutors studentsTutors)
    {
        return toAjax(studentsTutorsService.insertStudentsTutors(studentsTutors));
    }

    /**
     * 修改导师信息
     */
    @PreAuthorize("@ss.hasPermi('students:tutors:edit')")
    @Log(title = "导师信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentsTutors studentsTutors)
    {
        return toAjax(studentsTutorsService.updateStudentsTutors(studentsTutors));
    }

    /**
     * 删除导师信息
     */
    @PreAuthorize("@ss.hasPermi('students:tutors:remove')")
    @Log(title = "导师信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{tutorIds}")
    public AjaxResult remove(@PathVariable Long[] tutorIds)
    {
        return toAjax(studentsTutorsService.deleteStudentsTutorsByTutorIds(tutorIds));
    }
}
